from django.db import models

class NaturalLanguage(models.Model):
    identifier = models.CharField(max_length = 5)
    name = models.CharField(max_length = 64)
    
    def __unicode__(self):
        return ', '.join([self.identifier, self.name]);
    
    class Meta:
        ordering = ['identifier']

class ProgrammingLanguage(models.Model):
    name = models.CharField(max_length = 16)
    grammar = models.CharField(max_length = 16)

    def __unicode__(self):
        return u', '.join([self.name, self.grammar]);
    
    class Meta:
        ordering = ['name', 'grammar']

class Environment(models.Model):
    name = models.CharField(max_length = 16)
    version = models.CharField(max_length = 16)

    def __unicode__(self):
        return u', '.join([self.name, self.version]);
    
    class Meta:
        ordering = ['name', 'version']
    
class Utterance(models.Model):
    text = models.CharField(max_length = 64)
    natural_language = models.ForeignKey(NaturalLanguage)
    programming_languages = models.ManyToManyField(ProgrammingLanguage)

    def __unicode__(self):
        return u', '.join([self.text]);
    
    class Meta:
        ordering = ['text']

class VoiceCommand(models.Model):
    utterance = models.ForeignKey(Utterance)
    environments = models.ManyToManyField(Environment)

